package com.xinhe.web.session;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserSessionManagerFactory {

    @Value("${virtual.user.session:false}")
    private Boolean virtual;

    @ConditionalOnMissingBean({UserSessionManager.class})
    @Bean({"userSessionManager"})
    public UserSessionManager userSessionManager() {
        if (null != this.virtual && this.virtual.booleanValue()) {
            return new UserSessionManagerVirtual();
        }
        return new UserSessionManager();
    }
}
